<!--# layout("/common/leftmallout.html",{"jsBase":"/js/order/orderList/"}){ -->
<!-- 文件上传 -->

 <script type="text/javascript" src="/plugins/oss/js/plupload.full.min.js"></script>
   <!--   <script type="text/javascript" src="/plugins/oss/ziyun_library.js"></script>-->
   <script type="text/javascript" src="https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop%2Fmall%2Fstyle%2Flib%2Fplupload.full.min.js"></script>
     <script type="text/javascript" src="https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop%2Fmall%2Fstyle%2Flibrary.js"></script>
<link rel="stylesheet" href="http://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop/mall/style/member.css">
 <div class="center">
	<div class="section">
    	<!-------------面包屑--------------------->
    	<br>
        <!------------------主体结构--------------------->
        <div class="small-page">
        <!--左侧-->
        	
       <!-------左侧end-------->
       <!-------右侧-------->
            <div class="page-article">
            	<div class="area_mend_head">
                    <span>订单详情</span>
                </div>
                <div class="area_mend_head_box">
                	<p class="p_rod">
                    	<span class="active">1</span>
                        <i>拍下商品</i>
                    </p>
                    <p class="p_bor"></p>
                	<p class="p_rod">
                    	<span >2</span>
                        <i>付款成功</i>
                    </p>
                    <p class="p_bor"></p>
               		<p class="p_rod">
                    	<span>3</span>
                        <i>卖家发货</i>
                    </p>
                     <p class="p_bor"></p>
                    <p class="p_rod">
                    	<span>4</span>
                        <i>确认发货</i>
                    </p>
                </div>
                <div class="area_mend_body">
                	<div class="member_orders_title orders_title_new">
                    	<b> 订单状态</b>
                        <b>订单信息</b>
  					</div>
                    <div class="member_file_list_new">
                        <div class="member_file_list_new_l">
                        	<ul>
                            	<li>
                                	 <p id="orderStatusdemo"></p>
                                </li>
                                <li id="operationType"></li>
                            </ul>
                        </div>
                        <div class="member_file_list_new_r">
                        	<p id="shipNameAndMobile"></p>
                            <p id="shipAddr"></p>
                            <p id="orderTax"></p>
                            <p id="orderPayList"></p>
                            <p id="createtime"></p>
                        </div>
                    </div>
                </div>
                <!---------------------------->
                <div class="area_mend_body area_mend_bodyItem"></div>
                <!-------订单价格显示-------------------->
                <div class="order-odl-all">
                	<div class="order-odl-l">
                    	<p>订单备注</p>
                        <textarea id="memo"></textarea>
                    </div>
                    <div class="order-odl-r">
                    	<p><label>商品总金额：</label><span id="totalAmount"></span></p>
                        <p><label>运费：</label><span id="costFreight"></span></p>
                        <p><label>促销优惠：</label><span id="pmtGoods"></span></p>
                        <p><label>优惠券：</label><span id="pmtOrder"></span></p>
                        <p><label>随机立减：</label><span id="pmtRandom"></span></p>
                        <p><label><strong>支付总额：</strong></label><span><strong id="surplusPayed"></strong></span></p>
                    </div>
                </div>
                <!--------------------------->
            </div>
       <!-------右侧end-------->
        </div>
        <!------------------->
    </div>
     <input type="hidden" id="orderId" value="${orderId}">
</div>



<!--#} -->
<script>
//window.opener.location.href = window.opener.location.href;
layui.use(['indexDetail'], function(){
    var quoteOrderListIndex = layui.indexDetail
    quoteOrderListIndex.init();
});

	var html=$('.page-aside');
	var righthtml=$('.page-article');
	$('.small-page').empty();
	$('.small-page').append(html);
	$('.small-page').append(righthtml);
</script>

<script>

var orderId=$("#orderId").val();
doAjax('/order/orderInfo/getOrderInfoRequestVoById.json', 'post', {'orderId':orderId }, function(ret){
   if(ret.code=='200'){
	   var orderResult=ret.data;
	   var orderStatusdemo="";
	   var operationHtml="";
	   if(orderResult){
		   $('.area_mend_head_box').find('span').removeClass('active');
		   if(orderResult.orderStatus=="unauditing"){
			   $('.area_mend_head_box').find('span').eq(0).addClass('active');
			   orderStatusdemo="商品已拍下，等待商家审核";
			   operationHtml+='<span>您可以</span>'+'<a href="javascript:;" onclick="return cancelOrder( '+orderId+' );" style="text-decoration:none">取消订单</a>';
		   }else if(orderResult.orderStatus=="unpay"){
			   $('.area_mend_head_box').find('span').eq(0).addClass('active');
/*			   var id = setInterval(function () {
				    doAjax('/order/popGoDown/getPayOrderInfo.json', 'post', {'orderId':orderId}, function (res) {
				        if (res['code'] == '200') {
				            if (res.data.payStatus == '1') {
				                clearInterval(id);
				                window.location.href = "/order/orderInfo/lookOrderDetail.do?orderId="+orderId;
				            }
				        }
				    })
				}, 3000)*/
			   orderStatusdemo="商品已拍下，等待买家付款";
			   operationHtml+='<span>您可以</span>'+'<a href="/order/orderPay/goOrderPay.do?orderId='+orderId+'" target="_blank" class="active but_shop">立即付款</a>';
			   operationHtml+='<a href="javascript:;" onclick="return cancelOrder( '+orderId+' ); " style="text-decoration:none">取消订单</a>';
		   }else if(orderResult.orderStatus=="undeliver"){
			   $('.area_mend_head_box').find('span').eq(0).addClass('active');
			   $('.area_mend_head_box').find('span').eq(1).addClass('active');
			   orderStatusdemo="买家已付款，等待商家发货";
			  // operationHtml+='<a href="javascript:;" onclick="return confirmShipOrder( '+orderId+' );" style="text-decoration:none">确认收货</a>';
		   }else if(orderResult.orderStatus=="consign"){
			   $('.area_mend_head_box').find('span').eq(0).addClass('active');
			   $('.area_mend_head_box').find('span').eq(1).addClass('active');
			   $('.area_mend_head_box').find('span').eq(2).addClass('active');
			   orderStatusdemo="商家已发货";
			   operationHtml+='<span>您可以</span>'+'<a href="javascript:;" onclick="return confirmShipOrder( '+orderId+' );" style="text-decoration:none">确认收货</a>';
		   }else if(orderResult.orderStatus=="complete"){
			   $('.area_mend_head_box').find('span').eq(0).addClass('active');
			   $('.area_mend_head_box').find('span').eq(1).addClass('active');
			   $('.area_mend_head_box').find('span').eq(2).addClass('active');
			   $('.area_mend_head_box').find('span').eq(3).addClass('active');
			   orderStatusdemo="订单已完成";
		   }else if(orderResult.orderStatus=="canceled"){
			   orderStatusdemo="订单已取消";
			   operationHtml+='<span>您可以</span>'+'<a href="javascript:;" onclick="return deleteOrder( '+orderId+' );" style="text-decoration:none">删除订单</a>';
		   }else {
			   orderStatusdemo="无订单状态";
		   }
	   }
	   var shipNameAndMobileHtml="<label>联系人信息：</label>"+orderResult.shipName+orderResult.shipMobile;
	   var shipAddrHtml="<label>收货地址：</label>"+orderResult.shipAddr;
		var  orderTax=  orderResult.orderTax;
		var orderTaxHtml="";
	   if(orderTax){
		   if(orderTax.taxType=='companyOrdinary'&&orderResult.orderTax.taxCompany){
			   orderTaxHtml+="<label>发票信息：</label>"+orderResult.orderTax.taxCompany;
	  	 	}else if(orderTax.taxType=='unwanted'){
	  	 	  orderTaxHtml+="<label>发票信息：不开发票</label>";
	  	 	}else if(orderTax.taxType=='personal'){
		  	 	  orderTaxHtml+="<label>发票信息：个人发票</label>";
	  	 	}else if(orderTax.taxType=='companyOrdinary'){
		  	 	  orderTaxHtml+="<label>发票信息：公司发票</label>";
	  	 	}
	   }
	   if(orderResult.orderPayList&&orderResult.orderPayList.length>0){
		   var orderPayListHtml="<label>支付信息：</label>";
		   for(var i=0;i<orderResult.orderPayList.length;i++){
			   var orderPay=orderResult.orderPayList[i];
			   orderPayListHtml+=orderPay.payName;
		   }
	   }
	   var createtimeHtml="<strong>"+orderResult.createtime +"订单创建</strong>";
	   $("#orderStatusdemo").html(orderStatusdemo);
	   $("#operationType").append(operationHtml);
	   $("#shipNameAndMobile").append(shipNameAndMobileHtml);
	   $("#shipAddr").append(shipAddrHtml);
	   $("#orderTax").append(orderTaxHtml);
	   $("#orderPayList").append(orderPayListHtml);
	   $("#createtime").append(createtimeHtml);
	   var area_mend_bodyItemHtml='<div class="member_orders_title titlekind">'
							 +'<span>'+orderResult.createtime+'</span>'  
							 +'<span><strong>订单号：</strong>'+orderId+'</span>';
							 if(orderResult.suppInfoVo){
								  area_mend_bodyItemHtml+= '<b>'+orderResult.suppInfoVo.sellerName+'</b>';
							 }
							 area_mend_bodyItemHtml+='</div>';
	   var orderItems=orderResult.orderItem;
	   var l=0;
	   if(orderItems){
		   area_mend_bodyItemHtml+='<table class="member_file_list kind">';
		   for(var k=0;k<orderItems.length;k++){
			   var orderItem=orderItems[k];
			   l++;
			   area_mend_bodyItemHtml+='<tr>'
              						+' <td class="shop_g_img" valign="top">'
              						+'   <img class="imgJump" skuId="'+orderItem.goodsId+' " goodsType="'+orderItem.goodsType+' " src="${imagepath}/'+orderItem.goodsImgUrl+'">'
              						+' </td>'
              						+'<td class="shop_g_info">'
              						+'                  <h3 class="ship_g_h3">'+orderItem.name+'</h3>'
        	                		+'                   <p class="ship_g_name">'+orderItem.addon+'</p>'
              						+' <div class="ship_g_file">';
              						
              						
     					var orderStatus=orderResult.orderStatus;
                		if((orderStatus=='unauditing'||orderStatus=='unpay'||orderStatus=='paymentaudit'||orderStatus=='undeliver')&&orderItem.uploadFlag){
                			area_mend_bodyItemHtml+='    <p class="file_info_but">'
              						+'      <a href="javascript:" class="file_select_up">选择上传文件<!-- <i class="icon"></i>--></a>'
              						+'     <a href="javascript:" class="file_up webuploader-container" id="'+orderItem.orderItemId+'" order_num="'+l+'"orderItemId="'+orderItem.orderItemId+'" order_id="'+orderResult.orderId+'">文件上传</a>'
                                    +'  </p>';
                		}else{
                			area_mend_bodyItemHtml+='    <p >'
          						+'      <a href="javascript:" ><!-- <i class="icon"></i>--></a>'
          						+'     <a href="javascript:" class="file_up webuploader-container" id="'+orderItem.orderItemId+'" order_num="'+l+'"orderItemId="'+orderItem.orderItemId+'" order_id="'+orderResult.orderId+'"></a>'
                                +'  </p>';
                		}     
                                    
                                    
                                    
                		area_mend_bodyItemHtml+='<p class="file_info_name">'
                                    +'<span class="file_info_list">';
                if(orderItem.fileList&&orderItem.fileList.length>0){
                	for(var q=0;q<orderItem.fileList.length;q++){
    	            	var orderFileVo=orderItem.fileList[q];
    	            	area_mend_bodyItemHtml+='<em><a href="javascript:" style="text-decoration:none">'+orderFileVo.fileName+'</a><i class="del" style="display: inline-block;'
    	            	   		    +'width: 15px;height: 15px;cursor: pointer; margin-left: 15px; color: #f16c6c; line-height: 15px;text-align: center;" del_id="'+orderFileVo.foId+'">X</i></em>';
    	            }
                }
	            
                area_mend_bodyItemHtml+='</span>'  ;          
                if(orderItem.fileList&&orderItem.fileList.length>1){      
                	area_mend_bodyItemHtml+='<span class="moved"><em>更多</em><i class="icon" style="font-size:22px;"></i></span>';          
                }
                area_mend_bodyItemHtml+=' </p>'
                                    +' </div>'
                                    +'  </td>'
                                    +'<td>'
                                    +' <div class="shop_g_nume"> ￥'+orderItem.totalPrice+' </div>'
                                    +'</td>';
                if(k<1){
                	area_mend_bodyItemHtml+= ' <td rowspan='+orderResult.orderItem.length+'>'
                    +'  <div class="shop_g_status">'+orderResult.orderStatusName+'</div>'
                    +'</td>';
                }
                                   
                area_mend_bodyItemHtml+='</tr>';
		   }
		   area_mend_bodyItemHtml+='</table>';
		   
	   }
	   var costFreight=orderResult.costFreight;
	   var pmtGoods=orderResult.pmtGoods;
	   var pmtOrder=orderResult.pmtOrder;
	   var pmtRandom=orderResult.pmtRandom;
	   if(!costFreight){
		   costFreight=0;
	   }
	   if(!pmtGoods){
		   pmtGoods=0;
	   }
	   if(!pmtOrder){
		   pmtOrder=0;
	   }
	   if(!pmtRandom){
		   pmtRandom=0;
	   }
	   $(".area_mend_bodyItem").append(area_mend_bodyItemHtml);
	   $("#memo").html(orderResult.memo);//备注
	   $("#totalAmount").html("¥"+orderResult.totalAmount);//商品总金额
	   $("#costFreight").html("+ ¥"+costFreight);//运费
	   $("#pmtGoods").html("- ¥"+pmtGoods);//促销优惠
	   $("#pmtOrder").html("- ¥"+pmtOrder);//优惠券
	   $("#pmtRandom").html("- ¥"+pmtRandom);//随机立减
	   $("#surplusPayed").html("¥"+orderResult.payableAmount);//支付总额
	 $(document).on('click','.imgJump',function(){
       	var skuId =$(this).attr('skuId');
       	var goodsType =$(this).attr('goodsType');
       	window.location.href="/mall/skuProductDetails.do?goodsId="+skuId+"&goodsType="+goodsType;
   	 });
	 $(document).on('click','.but_shop',function(){
	        	 var orderId=$("#orderId").val();
	        	 $.confirm('',"支付完成后请点击确定..",function(){
	        		 window.location.href = "/order/orderInfo/lookOrderDetail.do?orderId="+orderId;
	  			},'',false);
	        	 
	        	 //关闭
	             $(".popup-btn-close").click(function(){
	                 window.location.href = url;
	                 return false;
	             });


	    	 });
	   /*增加文件 0507 gaoyangdi*/
   	$(".file_info_but").hover(function(e) {
   		$(this).find('.file_up').css("display","block").end().find(".icon").text("7");
   		$(this).find("div").css({"width":"100%","height":"60px"});
   	
   	},function(){
   		$(this).find('.file_up').css("display","none").end().find(".icon").text("6");
   	
   	});
   	var array=[];
   	$(".webuploader-container").each(function(i,o){
   		array.push($(o).attr('id'))
   	});
   	//上传文件
   	$.files_up_oss({
   					id:array,//按钮id
   			        url: "/oss/getSignatureNew",
   			        dir: "order/orderImage/",
   			        file_type: "jpg,png,gif,psd,ai,cdr,eps,ppt,word,excel,pdf,tiff,rar,zip,7z,gif",
   			        size: "100mb",//mb
   			        view_url: "https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/"					
   				},function(index_number,json){
   	                var orderItemId=$(".webuploader-container").eq(index_number).attr('id');
   	                var orderId=$("#orderId").val();
   					 if (json.Status == 'OK') {
   						 var orderItemId=$(".webuploader-container").eq(index_number).attr('id');
   						 var requestData={url:json.filename, 
   								 name:json.filename,
   								 size:json.size, 
   								 type:json.mimeType,
   								 uniqueId:orderItemId
   			                		}
   						 doAjax("/user/userAccessory/addAccessory.json", 'post', {'requestData':JSON.stringify(requestData)}, function(ret){
   							 var fileIdList=[];
   							 var fileId=ret.data.resultDtos[0].id;
   							 fileIdList.push(fileId);
   							 var orderFilesParamDto={orderId:orderId, 
   									 orderItemId:orderItemId,
   									 fileIdList:fileIdList 
       			                		};
   							 doAjax("/order/orderInfo/updateOrderFiles.json", 'post', {'requestData':JSON.stringify(orderFilesParamDto)}, function(ret){
   								 if(ret.code=='200'){
   				                        $.alert('success',"附件关联成功！");
   				                        location.href = location.href;
   				                    }
   							 });
   			                });
   					 }
   	}) 
	   
   }
  
});





function confirmShipOrder(orderId){
    doAjax('/order/orderInfo/updateOrderConfirmShip.json', 'post', {'orderId':orderId }, function(ret){
        if(ret.code=='200'){
            $.alert('success',"确认收货成功！");
            location.href = location.href;
        }
    });
    return false;
}

function cancelOrder(orderId){
    var str = '<input type="hidden" name="pop-orderId" value="'+ orderId +'">' +
            '<ul class="order_cancel">' +
            '<li class="form-item"><input type="radio" name="reasonType" value="0" checked="checked"> 不想要了</li>' +
            '<li class="form-item"><input type="radio" name="reasonType" value="1"> 支付不成功</li>' +
            '<li class="form-item"><input type="radio" name="reasonType" value="2"> 价格较贵</li>' +
            '<li class="form-item"><input type="radio" name="reasonType" value="3"> 缺货</li>' +
            '<li class="form-item"><input type="radio" name="reasonType" value="4"> 等待时间过长</li>' +
            '<li class="form-item"><input type="radio" name="reasonType" value="5"> 拍错了</li>' +
            '<li class="form-item"><input type="radio" name="reasonType" value="6"> 订单信息填写错误</li>' +
            '<li class="form-item"><input type="radio" name="reasonType" value="7"> 其他</li>' +
            '<li class="form-item"><input class="x-input" type="text" name="reasonDesc"></li>' +
            '<li class="form-item"><button type="submit" class="btn btn-caution act-subscribe btn-ordercancel">提交</button></li>' +
            '</ul>';

    $.prompt({
        style: '',
        title: '取消订单',
        con: str
    });

    return false;
}

//删除订单
function deleteOrder(orderId){
    $.confirm("删除订单","您确认要删除该订单吗?",function(){
        doAjax('/order/orderInfo/updateOrderDel.json', 'post', {'orderId':orderId}, function(ret){
            if(ret.code=='200'){
                $.alert('success',"订单删除成功！");
                window.location.href="/order/orderInfo/lookOrders.do";
            }
        });

    }, function(){$(".popup-btn-close").click();});

    return false;
}



$(document).on('click','.moved',function(){
	var h=$(".file_info_list").height();
	if(h==30)
		{
		$(".file_info_list").css("height","auto")
		}
	else{
		$(".file_info_list").css("height","30px")
	}
	
})

$(document).on('click','.del',function(){
	var foIds=$(this).attr('del_id');
	var th_is=$(this);
	doAjax("/order/orderInfo/updateOrderFilesDel.json", 'post', {'foIds':foIds}, function(ret){
		 if(ret.code=='200'){
               $.alert('success',"附件删除成功！");
               th_is.parents("em").remove();
           	if($(".file_info_list").find("em").length<=1)
           		{
           		$(".moved").css("display","none");
           		}
           }
	 });
	
})


</script>
